import 'package:floor/floor.dart';

///属性表

@entity
class AttributeBean {
  @PrimaryKey(autoGenerate: true)
  int? id;

  String attributeName = ''; //名称
  String attributeCode = ''; //code
  String attributeValue =
      ''; //属性值 1级属性，需要选择；2级属性，需要手动填写； （暂时支持2级，有parentCode，就提示不可以添加 子属性）
  int attributeLevel = 1; //属性等级
  String parentCode = ''; //父级属性code
  int searchType = 0; //是否支持搜索 0-不支持；1-支持

  String column1 = ''; //扩展字段1
  String column2 = ''; //
  String column3 = '';
  DateTime createTime; //创建时间
  DateTime updateTime; //更新时间
  int isDelete = 0; //是否删除，0-未删除，1-删除

  AttributeBean({
    this.id,
    this.attributeName = '',
    this.attributeCode = '',
    this.attributeValue = '',
    this.attributeLevel = 1,
    this.parentCode = '',
    this.searchType = 0,
    this.column1 = '',
    this.column2 = '',
    this.column3 = '',
    required this.createTime,
    required this.updateTime,
    this.isDelete = 0,
  });

  //自定义构造函数，会影响database.g.dart 的代码生成逻辑；要放在主构造函数后面
  AttributeBean.value({
    this.attributeName = '',
    this.attributeCode = '',
    this.attributeValue = '',
    required this.createTime,
    required this.updateTime,
  });

  Map<String, Object> toJson() {
    Map<String, Object> map = {};
    map['id'] = (id ??= -1);
    map['attributeName'] = attributeName;
    map['attributeCode'] = attributeCode;
    map['attributeValue'] = attributeValue;
    map['attributeLevel'] = attributeLevel;
    map['parentCode'] = parentCode;
    map['searchType'] = searchType;
    return map;
  }
}
